package com.hcom.configuration;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;

/**
 * @Description：
 * @Author：曹杰克
 * @CreateTime：2022/9/22 11:00
 */
@Configuration
public class RabbitConfiguration {


    /**
     * 声明交换机
     * @return
     */
    @Bean
    public TopicExchange exchangeTopic(){
        return  new TopicExchange("exchangetopic");
    }



    /**
     * 声明订阅货物队列
     * @return
     */
    @Bean
    public Queue noticegoods(){
        return  new Queue("noticegoods");
    }

    /**
     * 绑定
     * @param noticegoods
     * @param exchangeTopic
     * @return
     */
    @Bean
    public Binding bindingOrdergoods(Queue noticegoods ,TopicExchange exchangeTopic){
        //指定要绑定的队列 ，指定交换机  指定路由
        return  BindingBuilder.bind(noticegoods).to(exchangeTopic).with("hasgoodsnotice");
    }



}
